package controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class BmiController {

	
	
	@RequestMapping("/toBmi.do")
	public String toBmi() {
			
		return "toBmi";
		
	}
	
	@RequestMapping("/bmi.do")
	public String bmi(BmiParam bp,ModelMap mm) {
		
		double w = bp.getWeight();
		double h = bp.getHigh();
		double index=w/h/h;
		mm.addAttribute("index",index);
		
		if(index>24){
			mm.addAttribute("status","过重");
		}else if(index<19){
			mm.addAttribute("status","过轻");
		}else{
			mm.addAttribute("status","正常");
		}
		
		return "view";

	}

}
